package main

import "fmt"

func printType(data interface{}) {
	fmt.Printf("Value:%v Type:%T\n", data, data)
	switch a := data.(type) {
	case string:
		fmt.Printf("Value:%v Type:%T\n", a, a)
	case int:
		var num int = a
		fmt.Println(num)
		fmt.Printf("Value:%v Type:%T\n", a, a)
	}
}

func getDataType(data interface{}) string {
	switch data.(type) {
	case string:
		return "string"
	case int:
		return "int"
	default:
		return "未知类型"
	}
}

type animal interface {
	sayer
	Mover
}

type sayer interface {
	say()
}

type Mover interface {
	move()
}

type cat struct{}

type dog struct{}

func (c cat) say() {
	fmt.Println("喵喵喵")
}

func (d dog) say() {
	fmt.Println("汪汪汪")
}

func (d dog) move() {
	fmt.Println("狗会动")
}

func (c *cat) move() {
	fmt.Println("猫会上树")
}

type People interface {
	Speak(string) string
}

type Student struct{}

func (stu *Student) Speak(think string) (talk string) {
	if think == "sb" {
		talk = "你是个大帅比"
	} else {
		talk = "您好"
	}
	return
}

type WashingMachine interface {
	wash()
	dry()
}

type dryer struct{}

func (d dryer) dry() {
	fmt.Println("甩一甩")
}

type haier struct {
	dryer
}

func (h haier) wash() {
	fmt.Println("洗刷刷")
}

//定义万能入参的方法
func show(obj interface{}) {
	fmt.Printf("type:%T value:%v\n", obj, obj)
}
